This page last changed on Mar 30, 2009 by scytacki.

Example once you have an OTClass

			OTClass otClass = <details below>;

			System.out.println("" + otClass.getName());

			System.out.print("     extends ");
			ArrayList<OTClass> superTypes = otClass.getOTSuperTypes();
			for (OTClass superType : superTypes) {
				System.out.print(superType.getName() + " ");
			}
			System.out.println();
			
			ArrayList<OTClassProperty> properties = otClass.getOTAllClassProperties();
			if(properties == null || properties.size() == 0){
				System.out.println("   no class properties");
			}
			for (OTClassProperty otProperty : properties) {
				String propName = otProperty.getName();
				OTType otType = otProperty.getType();
				String typeName = "null type";
				if(otType != null){
					Class<?> typeClass = otType.getInstanceClass();
					typeName = typeClass.getName();
				}
				System.out.println("  " + propName + " : " + typeName);
			}

OTClassProperty also provides the default value for a property.

Getting an OTClass

If you are running inside of the OTrunk system already then you probably have an OTObject which is an instance of the OTClass you want. So in that case you can just do:

otObject.otClass()

If you don't have an otObject of the right type, but you do have an otObjectService, then your best option is to do (for example):

otObject = otObjectService.createObject(org.concord.otrunk.ui.OTImage.class);
otObject.otClass();

If you don't have an otObjectService and don't want to make one then you can do:

// this will return null if objectClass isn't a valid java Class which defines an OTClass
// an example of objectClass would be: org.concord.otrunk.ui.OTImage.class
OTClass otClass = ReflectiveOTClassFactory.singleton.registerClass(objectClass);
// This will add the properties for this new class plus any dependencies that
// were registered at the same time.
ReflectiveOTClassFactory.singleton.processAllNewlyRegisteredClasses();
// now you can call any of the reflective methods on the otClass
Document generated by Confluence on Jan 27, 2014 16:52